Class Seat

java.lang.Object
  extended by Seat

public class Seat
extends Object

Seat models a seat in a car in a passenger train.

Version:
1.1 September 23, 2012
Author:
Lynn Marshall, SCE

Constructor Summary
Seat(int seatNo, double cost)
          Constructs a new Seat with the specified seat number and ticket price.
 
Method Summary
 boolean book()
          If this seat is available, books it and returns true.
 boolean cancelBooking()
          If this seat is booked, cancels the booking and returns true.
 boolean isBooked()
          Returns true if someone has purchased a ticket for this this Seat.
 int number()
          Returns this seat's number.
 double price()
          Returns the cost of purchasing a ticket for this Seat.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Seat

public Seat(int seatNo,
            double cost)
Constructs a new Seat with the specified seat number and ticket price.

Parameters:
seatNo - The number of the seat.
cost - The cost of a ticket for this seat, in dollars.
Method Detail

book

public boolean book()
If this seat is available, books it and returns true. If the seat is not available, returns false.

Returns:
True if the seat was available and has been booked, false otherwise.

cancelBooking

public boolean cancelBooking()
If this seat is booked, cancels the booking and returns true. If the seat was not booked, returns false.

Returns:
True if the booking has been cancelled, false otherwise (the seat was not booked).

isBooked

public boolean isBooked()
Returns true if someone has purchased a ticket for this this Seat.

Returns:
True if the seat has been booked, false otherwise.

number

public int number()
Returns this seat's number.

Returns:
The number of this seat.

price

public double price()
Returns the cost of purchasing a ticket for this Seat.

Returns:
Cost of purchasing a ticket for this seat, in dollars.